package org.dreamwork.jasmine2.web.client;

import java.util.regex.Matcher;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 12-4-25
 * Time: 下午5:52
 */
public class OperaParser {
/*
Opera/9.80 (Windows NT 6.1; WOW64; U; zh-cn) Presto/2.10.229 Version/11.62
group[1]=2.10.229
group[2]=11.62

Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.10.229 Version/11.62
group[1]=2.10.229
group[2]=11.62

Opera/9.80 (Android 2.2; Linux; Opera Tablet/ADR-1204201824; U; zh-cn) Presto/2.10.254 Version/12.00
group[1]=2.10.254
group[2]=12.00

Opera/9.80 (X11; Linux x86_64; U; zh-cn) Presto/2.7.62 Version/11.01
group[1]=2.7.62
group[2]=11.01

Opera/9.80 (Macintosh; Intel Mac OS X 10.6.7; U; zh-cn) Presto/2.10.229 Version/11.62
group[1]=2.10.229
group[2]=11.62
 */
    public static UserAgent parse (Matcher m) {
        UserAgent agent = new UserAgent (m.group (0));
        agent.setType (BrowserType.Opera);
        OperationSystem os = OSParser.parseOS (m.group (0));
        agent.setOs (os);
        agent.setVersion (new Version (m.group (2)));
        RenderKernel kernel = new RenderKernel (RenderkernelType.Presto, new Version (m.group (1)));
        agent.setKernel (kernel);
        Architecture arch = os.getArchitecture ();
        agent.setDevice (DeviceTypeUtil.getDeviceType (arch));
        return agent;
    }
}